package com.atguigu.gmall.product.service.impl;

import com.atguigu.gmall.cache.aspect.annotation.MallCache;
import com.atguigu.gmall.common.constant.RedisConst;
import com.atguigu.gmall.product.eneity.BaseCategory1;
import com.atguigu.gmall.product.mapper.BaseCategory2Mapper;
import com.atguigu.gmall.product.mapper.BaseCategoryMapper;
import com.atguigu.gmall.product.service.BaseCategory2Service;
import com.atguigu.gmall.product.service.BaseCategoryService;
import com.atguigu.gmall.product.vo.CategoryTreeVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.annotations.Authorization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BaseCategoryServiceImpl extends ServiceImpl<BaseCategoryMapper , BaseCategory1> implements BaseCategoryService{

    @Resource
    BaseCategory2Mapper baseCategory2Mapper;

    /**
     * 获取所有商品分类
     * @return
     */
    @MallCache(cacheKey = RedisConst.CATEGORYS_CACHE)
    @Override
    public List<CategoryTreeVo> getCategoryTree() {

        return baseCategory2Mapper.getCategoryTree();
    }

    @Override
    public CategoryTreeVo getCategoryTreeWithC3Id(Long c3Id) {

        return baseCategory2Mapper.getCategoryTreeWithC3Id(c3Id);
    }
}
